Skip to content

Add open/close/stop_tonneau to TeslemetryVehicle - #185

Merged
Bre77 merged 1 commit into
mainfrom
fm/pytfa-teslemetry-tonneau-methods
Oct 12, 2026
Merged

Bre77 merged 1 commit into
mainfrom
fm/pytfa-teslemetry-tonneau-methods

Conversation

@Bre77

@Bre77 Bre77 commented Oct 12, 2026

Copy link
Copy Markdown
Member

VehicleRouter routes a call to Bluetooth only when both backends expose the method. The signed Commands class has open_tonneau/close_tonneau/stop_tonneau, but TeslemetryVehicle only had closure(tonneau=...), so tonneau always went to the cloud and Home Assistant needed a hand-built router.

This adds the three methods to TeslemetryVehicle, each calling closure(tonneau=...), with the same signatures and return type as the signed class. closure and the Bluetooth code are unchanged.

Tests: request path and body for each method, plus a VehicleRouter test showing Bluetooth is preferred and the cloud is used on failure. No release.

Mirror the signed Commands names via closure(tonneau=...) so VehicleRouter
can route tonneau commands to Bluetooth and fall back to the cloud.
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Teslemetry/coderabbit/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 873bd980-3e71-4289-bd1e-4c8b643e1bfe
📥 Commits

Reviewing files that changed from the base of the PR and between e4325cf and b5a04d8.

📒 Files selected for processing (2)
  • tesla_fleet_api/teslemetry/vehicle.py
  • tests/test_teslemetry_vehicle_custom_commands.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

📝 Walkthrough

Walkthrough

The vehicle API adds methods to open, close, and stop the tonneau cover. Tests check the command requests, responses, and BLE-to-cloud fallback.

Changes

Tonneau Controls

Layer / File(s) Summary
Tonneau commands and validation
tesla_fleet_api/teslemetry/vehicle.py, tests/test_teslemetry_vehicle_custom_commands.py
Adds methods that send open, close, and stop to the closure endpoint. Tests check the returned responses and verify that routing uses BLE when successful, then uses cloud after a BLE ConnectionError.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to b5a04

This change adds tonneau open, close and stop commands that reuse the existing closure command path. No actionable merge risk was identified.

Security Architecture Review

Security architecture risk: 🔵 Low · up to b5a04

The new methods reuse existing commands and preserve protection against replaying an ambiguously delivered Bluetooth command. No introduced security finding was established. Automatic cloud fallback changes command delivery, however, and correct vehicle pairing and downstream authorization remain important assumptions.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A routed call can attempt the configured eligible backend chain, not necessarily a single vehicle if the caller mispairs objects. Effective exposure depends on each backend's vehicle identity and existing credentials; the new wrappers introduce no caller-supplied target or action parameter.

Trust Boundaries and Controls

  • observed — Cloud commands retain the inherited bearer-token request path and VIN-specific endpoint. Bluetooth commands retain existing VIN-bound signing. Fallback selects another independently credentialed backend; the wrappers do not transfer Bluetooth authority into cloud credentials. Cloud-side token-to-VIN authorization is outside the inspected client source.

Resilience and Maintainability Implications

  • observed — BluetoothUnconfirmedCommand is re-raised without cloud replay. Bluetooth write handling distinguishes provable pre-submission failure from ambiguous delivery, and sends use a per-domain session lock. Cancellation propagates rather than triggering router fallback, although it cannot undo an already submitted physical command. The router adds no cross-backend transaction, deduplication, or global ordering guarantee.

Hardening Proposals

  • proposed — As defense in depth, consider validating matching VINs when constructing a VehicleRouter, or explicitly documenting and enforcing that precondition in consumers. This addresses an existing caller-owned invariant, not an established exploit introduced by this PR.
Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the three methods added to TeslemetryVehicle. It matches the main change.
Description check Passed The description accurately explains the new tonneau methods, routing behavior, and test coverage. It is related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@Bre77
Bre77 merged commit f591495 into main Oct 12, 2026
7 checks passed
@Bre77
Bre77 deleted the fm/pytfa-teslemetry-tonneau-methods branch October 12, 2026 23:55
@Bre77 Bre77 mentioned this pull request Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant